package com.lxl.xm.controller;

import com.lxl.xm.common.BaseResponse;
import com.lxl.xm.common.DailyEarning;
import com.lxl.xm.common.DailyRegistration;
import com.lxl.xm.common.ResultUtils;
import com.lxl.xm.model.entity.AdCampaign;
import com.lxl.xm.service.AdCampaignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/adcampaign")
@Slf4j
public class AdCampaignController {
    @Resource
    AdCampaignService adCampaignService;

    /**
     * 近七天收益数据
     * @return
     */
    @GetMapping("EarningOflastSevenDays")
    public BaseResponse<List<DailyEarning>> getRegisteredStudentsLast7Days(){
        return ResultUtils.success(adCampaignService.getEarningLast7Days());
    }

    /**
     * 点击次数排行榜
     * @param limit
     * @return
     */
    @GetMapping("/top-clicks")
    public BaseResponse<List<AdCampaign>>getTopCampaignsByClicks(@RequestParam(name="limit",defaultValue = "10")int limit){
        List<AdCampaign>campaigns = adCampaignService.getTopCampaignsByClicks(limit);
        return ResultUtils.success(campaigns);
    }
}
